//
//  QBRequest.m
//  Doctor
//
//  Created by 阳光 on 16/9/14.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "QBRequest.h"
#import "Request.h"

@implementation QBRequest

// 注册
+(void)RegisterWithDic:(NSDictionary *)dic Success:(void (^)(id))success
               failure:(void (^)(id))failure
{
    [Request PostCallBack:URL(@"Doctoruser/register") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
    
}

// 登录
+(void)LoginWithDic:(NSDictionary *)dic Success:(void (^)(id))success
               failure:(void (^)(id))failure
{
    [Request PostCallBack:URL(@"Doctoruser/doctor_login") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
             //NSLog(@"message :%@", responseObj[@"message"]);
             NSString *message = responseObj[@"message"];
             if ([message isEqualToString:@"密码为字母、数字 不允许有符号最少8位最多16位"]) {
                 [self getAppDelegateByErrorMessage:NSLocalizedString(@"Pass limit", nil)];
             } else if ([message isEqualToString:@"用户名或密码错误"]){
                 [self getAppDelegateByErrorMessage:NSLocalizedString(@"Username or password error", nil)];//.
             } else {
                 [self getAppDelegateByErrorMessage:responseObj[@"message"]];
             }
            
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}

// 获取国家信息
+(void)GetCountryInfoWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                     failure:(void (^)(id))failure
{
    // URL_Token_Key(@"State/getcountry")
    [Request PostCallBack:URL(@"State/getcountry") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}

// 获取已存在的地区
+(void)GetAreaInfoWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                  failure:(void (^)(id))failure
{
    // URL_Token_Key(@"State/get_doctor_city")
    [Request PostCallBack:URL(@"State/get_doctor_city") parameter:dic success:^(id responseObj)
     {
    
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
    
}

// 获取医院列表
+(void)GetHospitalInfoWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                      failure:(void (^)(id))failure
{
    // URL_Token_Key(@"State/get_doctor_shop")
    [Request PostCallBack:URL(@"State/get_doctor_shop") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}

// 忘记用户密码
+(void)ForgetUserNameOrPasswordWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                               failure:(void (^)(id))failure
{
    // URL_Token_Key(@"Doctoruser/forget_password")
    [Request PostCallBack:URL(@"Doctoruser/forget_password") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
    
}

// 修改密码
+(void)ModifyPdWithDic:(NSDictionary *)dic Success:(void (^)(id))success
               failure:(void (^)(id))failure
{
    // URL_Token_Key(@"Doctoruser/retrieve_pass")
    [Request PostCallBack:URL(@"Doctoruser/retrieve_pass") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}


// 重置密码
+(void)ResetPdWithDic:(NSDictionary *)dic Success:(void (^)(id))success
              failure:(void (^)(id))failure
{
    // URL_Token_Key(@"Doctoruser/reset_pass")
    [Request PostCallBack:URL_Token_Key(@"Doctoruser/reset_pass") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}


// 获取会员个人信息
+(void)UserInfoWithDic:(NSDictionary *)dic Success:(void (^)(id))success
               failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctorauth/verification") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
         [self getAppDelegateByErrorMessage:responseObj[@"message"]];
        }
        
    } failure:^(NSError *error)
     {
         
     }];
}

// 获取预约时间详情
+(void)OrderTimeListWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                    failure:(void (^)(id))failure
{
//    NSLog(@"002002--%@",URL_Token_Key(@"Bookingtime/bookingTimeList"));
    
    [Request PostCallBack:URL_Token_Key(@"Bookingtime/bookingTimeList") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] integerValue]==0)
        {
            success(responseObj);
        }
        else
        {
          [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 添加取消视频预约
+(void)AddOrderTimeWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                   failure:(void (^)(id))failure
{
   
    [Request PostCallBack:URL_Token_Key(@"Bookingtime/addBookingTime") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] integerValue]==0)
        {
            success(responseObj);
        }
        else
        {
         [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
    
}

// 个人简介修改
+(void)ModifyDoctorInfoProfileWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                              failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctorauth/doctor_descript") parameter:dic success:^(id responseObj){
      
        if ([responseObj[@"status"] integerValue]==0)
        {
            success(responseObj);
        }
        else
        {
         [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 获取名医发布列表
+(void)DoctorPublicListWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                       failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Bbs/get_doctor_list") parameter:dic success:^(id responseObj){
            if ([responseObj[@"status"] isEqualToString:@"0"])
            {
                success(responseObj);
            }
            else
            {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
                
            }
    } failure:^(NSError *error)
     {
         
     }];
    
}

// 在线模式开启或者关闭
+(void)OnlineOrOutlineSwitchWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                            failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Onlinestate/state") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
         [self getAppDelegateByErrorMessage:responseObj[@"message"]];
             
         }
     } failure:^(NSError *error)
     {
         
     }];
}

// 获取医生所在的医院
+(void)DoctorHospitalListWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                         failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Bookingtime/getBookingShop") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
//          [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error)
     {
         
     }];
}

// 获取名医发布列表详情
+(void)DoctorPublicListDetailWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                       failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Bbs/get_content_by_id") parameter:dic success:^(id responseObj)
    {
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 上传认证资料
+(void)ConfirmWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                  failure:(void (^)(id))failure
{
    // Doctorauth/execute
    [Request PostCallBack:URL_Token_Key(@"Doctorauth/execute") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
             if ([responseObj[@"message"] isEqualToString:@"邮箱格式错误"]) {
                 [self getAppDelegateByErrorMessage:responseObj[@"message"]];
             } else {
                 [self getAppDelegateByErrorMessage:responseObj[@"message"]];
             }
            
         }
     } failure:^(NSError *error)
     {
         
     }];
}

// 获取评论列表
+(void)CommentListWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                  failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Bbs/get_comment") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
             
         }
     } failure:^(NSError *error)
     {
         
     }];
    
}

// 名医发布新增内容
+(void)AddNewDoctorPublicWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                         failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Bbs/doctor_content") parameter:dic success:^(id responseObj)
     {
         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
     } failure:^(NSError *error)
     {
         
     }];
}

// 上传认证资料
+(void)ConfirmInfoUploadWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                        failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctorauth/execute") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 取消上传认证资料
+(void)CancelConfirmInfoUploadWithDic:(NSDictionary *)dic Success:(void (^)(id))success
                              failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctorauth/auth_cancel") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
        [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 添加医嘱
+(void)AddDoctorAdviceWithDic:(NSDictionary *)dic Success:(void (^)(id))success failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctoradvice/add_advice") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
        [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}


// 获取就诊中的医嘱  医嘱详情页面提交与未提交
+(void)GetDoctorAdviceVisitPatientWithDic:(NSDictionary *)dic Success:(void (^)(id))success failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctoradvice/get_advice") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
        [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
     {
         
     }];
}

// 获取就诊列表
+(void)GetVisitPatientListWithDic:(NSDictionary *)dic Success:(void (^)(id))success failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"Doctortreatment/treatment") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
         [self getAppDelegateByErrorMessage:responseObj[@"message"]];
            
        }
    } failure:^(NSError *error)
    {
        
    }];
}

// 获取初诊就诊病例
+(void)GetPatientInfoWithDic:(NSDictionary *)dic Success:(void (^)(id))success failure:(void (^)(id))failure
{
    [Request PostCallBack:URL_Token_Key(@"doctortv/getCases") parameter:dic success:^(id responseObj){
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
        [self getAppDelegateByErrorMessage:responseObj[@"message"]];
        }
    } failure:^(NSError *error)
     {
         
     }];
}


// 用户执照图片上传
+(void)ConfirmInfoUserCodeUrlUploadWithImage:(UIImage *)image userId:(NSString *)userId success:(void (^)(id))success failure:(void (^)(id))failure
{
    NSString *urlParam=@"Doctorauth/upload_image";
    
    [QBRequest UploadImageUserCodeUrlToQNAndService:image userId:userId urlParam:urlParam success:^(id response){
        
        if ([response[@"status"] isEqualToString:@"0"])
        {
            success(response);
        }
        else
        {
            [self getAppDelegateByErrorMessage:response[@"message"]];
        }
        
    } failure:^(NSError *error){
        
        
        failure(error);
        
    }];
}


// 名医发布新增上传图片
+(void)AddNewDoctorPublicUploadPhotoWithImage:(UIImage *)image userId:(NSString *)userId success:(void (^)(id))success failure:(void (^)(id))failure
{
    NSString *urlParam=@"Bbs/doctor_content";
    
      [QBRequest UploadImageToQNAndService:image userId:userId urlParam:urlParam success:^(id response){
        
        if ([response[@"status"] isEqualToString:@"0"]){
            
            success(response);
            
        }
        else
        {
            
           [self getAppDelegateByErrorMessage:response[@"message"]];
        }
        
    } failure:^(NSError *error){
        
        
        failure(error);
        
    }];

    
}


// 用户修改头像
+(void)ConfirmInfoUserHeadUrlUploadWithImage:(UIImage *)image userId:(NSString *)userId success:(void (^)(id))success failure:(void (^)(id))failure
{
    NSString *urlParam=@"Doctorauth/upload_image";
    
    [QBRequest UploadImageToQNAndService:image userId:userId urlParam:urlParam success:^(id response){

        
        if ([response[@"status"] isEqualToString:@"0"]){
            
            success(response);
            
        }
        else{
            
//            [self getAppDelegateByErrorMessage:response[@"message"]];
        }
        
    } failure:^(NSError *error){
        
        
        failure(error);
        
    }];
    
}

//七牛上传图片:
+ (void)UploadImageToQiNiu:(UIImage *)uploadImage userId:(NSString *)userId success:(void (^)(id))success failure:(void (^)(id))failure
{
    //图片压缩
    uploadImage = [Tool scaleToSize:uploadImage size:CGSizeMake(180,uploadImage.size.height*(180.0/MAX(uploadImage.size.width,180)))];
    //图片转向处理
    uploadImage =[uploadImage fixOrientation];
    
    //获取当前时间
    NSDate *date=[NSDate date];
    NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyyMMddHHmmssss"];
    
    NSData *imageData = UIImageJPEGRepresentation(uploadImage,0.9f);
    NSString *uniquePath=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@-%@.png",[formatter stringFromDate:date], userId]];
    
    
    // YES是保证文件的写入原子性,就是说会先创建一个临时文件,直到文件内容写入成功再导入到目标文件里.NO是直接写入
    [imageData writeToFile:uniquePath atomically:NO];
    //NSLog(@"Upload Image Size: %lu KB",[imageData length] / 1024);
    
    
    NSString *token=[self tokenWithScope:QiniuBucketName];
    /**
     管理上传的类，可以生成一次，持续使用，不必反复创建。
     */
    QNUploadManager *upManager=[[QNUploadManager alloc] init];
    NSData *data=[NSData dataWithContentsOfFile:uniquePath];
    NSString *key=[NSURL fileURLWithPath:uniquePath].lastPathComponent;
    QNUploadOption *opt=[[QNUploadOption alloc] initWithMime:nil
                                             progressHandler:^(NSString *key, float percent){ }
                                                      params:@{ @"x:foo":@"fooval" }
                                                    checkCrc:YES
                                          cancellationSignal:nil];
    /**
     *    直接上传数据
     *
     *    @param data              待上传的数据
     *    @param key               上传到云存储的key，为nil时表示是由七牛生成
     *    @param token             上传需要的token, 由服务器生成
     *    @param completionHandler 上传完成后的回调函数
     *    @param option            上传时传入的可选参数
     */
    [upManager putData:data key:key token:token
              complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
                  
                  if (!info.error) {
                      
                      if (info.statusCode == 200) {
                          
                          NSString *contentURL = [NSString stringWithFormat:@"%@%@",QiniuBaseURL,key];
                          //NSLog(@"QN UploadImageURL = %@",contentURL);
                          
                          
                          success(contentURL);
                          
                          
                      } else {
                          
                      }
                      
                      
                  }else{
                      failure(info.error);
                  }
                  
              } option:opt];
    
}

+ (NSString *)tokenWithScope:(NSString *)scope
{
    QiniuPutPolicy *policy = [QiniuPutPolicy new];
    policy.scope = scope;
    return [policy makeToken:QiniuAccessKey secretKey:QiniuSecretKey];
}

// 执照图片修改
+(void)UploadImageUserCodeUrlToService:(NSString *)image userId:(NSString *)userId urlParam:(NSString *)urlParam success:(void (^)(id))success failure:(void (^)(id))failure
{
    
    NSDictionary *param = @{@"auth_img":image, @"doctor_id":userId};
    //    NSLog(@"imgUrl000 :%@", URL_Token_Key(urlParam));
    
    [Request PostCallBack:URL_Token_Key(urlParam) parameter:param success:^(id responseObj){
        
        //        NSLog(@"picUpload---%@",responseObj);
        if ([responseObj[@"status"] isEqualToString:@"0"]){
            
            success(responseObj);
            
            
        }else{
            
        }
        
    } failure:^(NSError *error){
        
        failure(error);
        
    }];
}

// 图片修改
+(void)UploadImageToService:(NSString *)image userId:(NSString *)userId urlParam:(NSString *)urlParam success:(void (^)(id))success failure:(void (^)(id))failure
{
    
    NSDictionary *param = @{@"img":image, @"doctor_id":userId};
//    NSLog(@"imgUrl000 :%@", URL_Token_Key(urlParam));
    [Request PostCallBack:URL_Token_Key(urlParam) parameter:param success:^(id responseObj){
        
//        NSLog(@"picUpload---%@ ---%@",responseObj,responseObj[@"message"]);
        if ([responseObj[@"status"] isEqualToString:@"0"]){
            
            success(responseObj);
            
        }
        else
        {
            
        }
        
    } failure:^(NSError *error){
        
        failure(error);
        
    }];
}

//上传医生执照图片(1张);
+(void)UploadImageUserCodeUrlToQNAndService:(UIImage *)uploadImage userId:(NSString *)userId urlParam:(NSString *)urlParam success:(void (^)(id))success failure:(void (^)(id))failure
{
    [QBRequest UploadImageToQiNiu:uploadImage userId:userId success:^(id response) {
        
        NSString *imageUrl = response;
        //        NSLog(@"imageUrl011111 :%@", imageUrl);
        [QBRequest UploadImageUserCodeUrlToService:imageUrl userId:userId urlParam:urlParam success:^(id res) {
            
            success(res);
            
        } failure:^(NSError *error)
         {
             failure(error);
         }];
    } failure:^(NSError *error)
     {
         failure(error);
     }];

    
}

//上传图片(1张);
+(void)UploadImageToQNAndService:(UIImage *)uploadImage userId:(NSString *)userId urlParam:(NSString *)urlParam success:(void (^)(id))success failure:(void (^)(id))failure
{
    [QBRequest UploadImageToQiNiu:uploadImage userId:userId success:^(id response) {
        
        NSString *imageUrl = response;
//        NSLog(@"imageUrl011111 :%@", imageUrl);
        [QBRequest UploadImageToService:imageUrl userId:userId urlParam:urlParam success:^(id res) {
            
            success(res);
            
        } failure:^(NSError *error)
        {
            failure(error);
        }];
    } failure:^(NSError *error)
     {
        failure(error);
    }];
}

// 获取今日手术
+(void)GetTodayDoneWithDocID:(NSString *)docID startTag:(NSString *)startTag endTag:(NSString *)endTag Success:(void (^)(id))success failure:(void (^)(id))failure
{
    NSInteger doctorId = [docID integerValue];
    
    NSDictionary *param = @{@"doctor_id":@(doctorId), @"start_tag":startTag, @"end_tag":endTag};
    
    [Request PostCallBack:URL_Token_Key(@"Doctorindex/operation") parameter:param success:^(id responseObj){
        
        
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
        }
        
    } failure:^(NSError *error){
        
        NSLog(@"error :%@", error);
        
    }];
}

// 获取今日预约
+(void)GetTodayFirstConsultWithDocID:(NSString *)docID startTag:(NSString *)startTag endTag:(NSString *)endTag Success:(void (^)(id))success failure:(void (^)(id))failure
{
    
    NSInteger doctorId = [docID integerValue];
    
    NSDictionary *param = @{@"doctor_id":@(doctorId), @"start_tag":startTag, @"end_tag":endTag};

    //NSLog(@"param888 :%@", param);

    [Request PostCallBack:URL_Token_Key(@"Doctorindex/appointment") parameter:param success:^(id responseObj){
        
        //NSLog(@"response888 :%@", responseObj);

         if ([responseObj[@"status"] isEqualToString:@"0"])
         {
             success(responseObj);
         }
         else
         {
           [self getAppDelegateByErrorMessage:responseObj[@"message"]];
         }
         
     } failure:^(NSError *error){
         
         NSLog(@"error :%@", error);
         
     }];
}



// 提示框
- (void)showMessageByMessage:(NSString *)message
{
    [AlertLabel hudShowText:message];
}


+(void)getAppDelegateByErrorMessage:(NSString *)message
{
    
    AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
    
    [delegate showMessageByMessage:message];
    
}



// 版本更新
+(void)IsNewVersionWithSuccess:(void (^)(id))success failure:(void (^)(id))failure
{
    [Request PostCallBack:URL(@"Myuser/doctor_version") parameter:nil success:^(id responseObj){
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
            [self getAppDelegateByErrorMessage:responseObj[@"message"]];
        }
        
    } failure:^(NSError *error)
     {
         
     }];
    
}

//医生确认视频订单
+(void)DoctorSureThisOrderWithDocID:(NSString *)docID orderId:(NSString *)orderId Success:(void (^)(id))success failure:(void (^)(id))failure{
    
    NSInteger doctorId = [docID integerValue];
    NSDictionary *param = @{@"doctor_id":@(doctorId), @"order_id":orderId};
    //NSLog(@"param888 :%@", param);
    
    [Request PostCallBack:URL_Token_Key(@"Doctorindex/editor_order_status") parameter:param success:^(id responseObj){
        
        //NSLog(@"response888 :%@", responseObj);
        if ([responseObj[@"status"] isEqualToString:@"0"])
        {
            success(responseObj);
        }
        else
        {
          [self getAppDelegateByErrorMessage:responseObj[@"message"]];
        }
        
    } failure:^(NSError *error){
        
        NSLog(@"error :%@", error);
        
    }];
}


@end

